package com.ruoyi.quartz.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.domain.biz.BizYfPerson;
import com.ruoyi.system.service.biz.IBizYfPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{
    @Autowired
    private IBizYfPersonService bizYfPersonService;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    public void saveYfInfo()
    {

        String json = HttpUtils.sendGet("https://oa.yfdyf.com/yst-prod-oaSupport/nTo2Work?begindate=2018-01-01&enddate=2022-12-30&uid=22&hrmids=22&begintime=00:00&endtime=23:59");
        JSONArray jsonArray = JSONObject.parseArray("["+json+"]");
        for (Object o : jsonArray) {
            JSONObject obj = (JSONObject) o;
            JSONArray jsonArray1 = obj.getJSONArray("responseJson");
            for (Object o1 : jsonArray1) {
                JSONObject obj1 = (JSONObject) o1;
                BizYfPerson person = new BizYfPerson();
                String name = (String) obj1.get("name");
                String endTime = (String) obj1.get("endtime");
                String beginTime = (String) obj1.get("begintieme");
                String addressName = (String) obj1.get("addressName");
                Integer memberId = (Integer) obj1.get("memberid");
                String meetingId = (String) obj1.get("meetingId");
                String description = (String) obj1.get("description");
                person.setName(name);
                person.setEndTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,endTime+":00"));
                person.setBeginTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,beginTime+":00"));
                person.setAddressName(addressName);
                person.setMemberId(memberId.longValue());
                person.setMeetingId(Long.valueOf(meetingId));
                person.setDescription(description);
                bizYfPersonService.insertBizYfPerson(person);
            }
        }
    }


}
